package cqie.edu.homework2.mapper;

import cqie.edu.homework2.domain.po.TUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cqie.edu.homework2.domain.vo.TUserVo;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

/**
* @author 86182
* @description 针对表【t_user(用户基本信息表)】的数据库操作Mapper
* @createDate 2025-03-26 17:58:06
* @Entity cqie.edu.homework2.domain.po.TUser
*/
public interface TUserMapper extends BaseMapper<TUser> {


    TUser selectByUsername(String username);

    Long insert1(TUser user);


    //用户表和用户明细表连表查询
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "userDetail", column = "id",
                    one = @One(select = "cqie.edu.homework2.mapper.TUserDetailMapper.selectByUserId",
                            fetchType = FetchType.EAGER))
    })
    @Select("SELECT * FROM t_user WHERE id = #{id}")
    TUserVo selectUserWithDetail(Long id);


}




